package com.ysg.utils;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

import com.ysg.base.BaseApplication;

public class YAppUtil {
    /**
     * 获取应用包名
     */
    public static String getPackageName() {
        Context context = BaseApplication.getContext();
        String packageName = context.getPackageName();
        return packageName;
    }

    /**
     * 获取本地软件版本号
     */
    public static String getVersionName() {
        String versionName = "";
        try {
            Context context = BaseApplication.getContext();
            PackageInfo packageInfo = context.getApplicationContext()
                    .getPackageManager()
                    .getPackageInfo(context.getPackageName(), 0);
            versionName = packageInfo.versionName;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return versionName;
    }


}
